#include <gtest/gtest.h>
#include "SeqList.h"  // 包含你的顺序表类头文件

// 测试构造函数
TEST(SeqListTest, Constructor) {
    SeqList list(10);
    EXPECT_TRUE(list.IsEmpty());
    EXPECT_EQ(list.Length(), 0);
}

// 测试插入操作
TEST(SeqListTest, InsertAndGet) {
    SeqList list(10);
    EXPECT_TRUE(list.Insert(1, 10));
    EXPECT_EQ(list.Get(1), 10);
    EXPECT_EQ(list.Length(), 1);

    list.PushBack(20);
    list.PushBack(5);
    list.PushBack(11);
    list.PushBack(8);
    list.PushBack(9);
    //10 20 5 11 8 9

    list.Insert(3, 10000);//10 20 10000 5 11 8 9
    EXPECT_EQ(list.Get(3), 10000);
}

// 测试删除操作
TEST(SeqListTest, Delete) {
    SeqList list(10);
    list.Insert(1, 5);
    list.Insert(2, 10);
    EXPECT_TRUE(list.Delete(1));
    EXPECT_EQ(list.Get(1), 10);
    EXPECT_EQ(list.Length(), 1);
}

// 测试查找操作
TEST(SeqListTest, Find) {
    SeqList list(10);
    list.Insert(1, 100);
    list.Insert(2, 200);
    EXPECT_EQ(list.Find(100), 0);
    EXPECT_EQ(list.Find(999), -1);
}

// 测试清空操作
TEST(SeqListTest, Clear) {
    SeqList list(10);
    list.Insert(0, 1);
    list.Insert(1, 2);
    list.Clear();
    EXPECT_TRUE(list.IsEmpty());
    EXPECT_EQ(list.Length(), 0);
}

int main() {
    ::testing::InitGoogleTest();
    return RUN_ALL_TESTS();
}